-- Module Definition
module Flminimodelchecker where

---- a Node is an index and an adjacency list ----
data Node = Node Integer [Integer] 
	deriving Show

---- Function Definition: makeNode
---- Require: an integer labeling the Node and a list of 
---- integer, i.e. Nodes, adjacenting to the Node
---- Return: a Node
makeNode :: Integer -> [(Integer, Integer)] -> Node
makeNode index edgeList = Node index
	((map (\x -> snd x) (filter (\x -> (fst x) == index) edgeList))
	++ (map (\x -> fst x) (filter (\x -> (snd x) == index) edgeList)))
	
---- Some useful functions
getAdjacentList (Node _ b) = b
getId(Node a _) = a

---- a Graph is a list of nodes ----
data Graph = Graph [Node]
	deriving Show

-- Function Definition: enumerateList
-- Require: a integer i
-- Return a list[1,2,...,i]
enumerateList :: Integer -> [Integer]
enumerateList i = 
	if i < 1 then
		[]
	else
		i : (enumerateList (i - 1))

---- Function Definition: makeGraph
---- Require: the number of nodes and a list of edges
---- Return: a Graph
makeGraph :: Integer -> [(Integer, Integer)] -> Graph
makeGraph numberOfNodes edges = Graph 
	(map (\x -> makeNode x edges) (enumerateList numberOfNodes))
	

